package chen.web.util;

import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean;
import java.lang.management.OperatingSystemMXBean;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;



public class Test {
	
	public static void main(String[] args){
		printUsage();
	}

	private static void printUsage() {
		OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();
		System.out.println(operatingSystemMXBean.getAvailableProcessors());
		  for (Method method : operatingSystemMXBean.getClass().getMethods()) {
		    method.setAccessible(true);
		    if (method.getName().startsWith("get") 
		        && true) {
		            Object value;
		        try {
		            value = method.invoke(operatingSystemMXBean);
		        } catch (Exception e) {
		            value = e;
		        } // try
		        System.out.println(method.getName() + " = " + value);
		    } // if
		  } // for
		}
}
